<template>
  <div class="body">
    <div class="top">
      <img src="../../assets/dimg/d_about_img_logo.png" alt />
    </div>
  </div>
</template>

<script>
import { axiosPost, axiosPostnotoken } from '../../axios';

export default {
  name: '',
  data() {
    return {
      msgText: '',
    };
  },
  created() {
    console.log(this.isWeiXin() + '微信浏览器');
    if (this.isWeiXin()) {
      let code = this.getUrlKey('code'); //获取url参数code
      if (code) {
        if (!sessionStorage.openid) {
          let data = {
            code: code,
          };
          axiosPostnotoken('index/get_openid', data, (res) => {
            console.log(res);
            if (res.code == 1) {
              sessionStorage.openid = res.data.openid;
              this.$router.push({ path: '/member' });
            }
          });
        } else {
          this.$router.push({ path: '/member' });
        }
      } else {
        this.getCodeApi(parseInt(Math.random() * 100000000, 10) + 1);
      }
    }
  },
  mounted() {
    this.getMsg();
  },
  methods: {
    //获取授权
    getCodeApi(state) {
      //获取code
      let urlNow = encodeURIComponent(window.location.href);
      let scope = 'snsapi_base'; //snsapi_userinfo   //静默授权 用户无感知
      let appid = 'wxc30ea135f753e8dc';
      let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${urlNow}&response_type=code&scope=${scope}&state=${state}#wechat_redirect`;
      window.location.replace(url);
    },
    getMsg() {
      axiosPost('About/aboutus', {}, (res) => {
        this.msgText = res.data[0];
      });
    },
  },
};
</script>

<style scoped lang="less">
@import '../../style/default';

.top {
  height: 4.1rem;
  background: @color4;

  img {
    width: 3.96rem;
    height: 2.64rem;
    margin: 0.92rem 0 0 2.1rem;
  }
}

p {
  margin-top: 0.3rem;
  color: @color2;
  font-size: @font28;
  padding: 0.4rem;
  line-height: 0.48rem;
  background: #fff;
  text-indent: 2em;
  span {
    width: 2em;
    display: inline-block;
  }
}
</style>
